package com.yxq.mdt.app.modules.personal.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.ToastUtils;
import com.orhanobut.hawk.Hawk;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.base.BaseActivity;
import com.yxq.mdt.app.constant.SPKey;
import com.yxq.mdt.app.modules.main.bean.NameAndPhoneBean;
import com.yxq.mdt.app.modules.market.bean.MallResponseBean;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 客服中心
 */
public class MainPersonalCustomerServiceAc extends BaseActivity {

    @BindView(R.id.cs_tv_phone)
    TextView csTvPhone;
    @BindView(R.id.cs_btn_call)
    Button csBtnCall;
    String contactTel;

    @Override
    public int getLayoutId() {
        return R.layout.activity_main_personal_customer_service;
    }

    @Override
    public void initView() {
        NameAndPhoneBean mallResponseBean = Hawk.get(SPKey.SP_KEY_NAME_PHONE_INFO);

        if (mallResponseBean != null && mallResponseBean.getContact_tel() != null) {

            if (!TextUtils.isEmpty(mallResponseBean.getContact_tel())) {
                contactTel = mallResponseBean.getContact_tel();
                csTvPhone.setText(String.format("客服电话：%s", contactTel));
            }
        }
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

    }

    @OnClick(R.id.cs_btn_call)
    public void onViewClicked() {
        call();
    }

    private void call() {
        if (TextUtils.isEmpty(contactTel)) {
            ToastUtils.showShort("无联系电话");
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:" + contactTel));
        startActivity(intent);
    }
}
